public class SolutionOffer20 {
    public boolean isNumber(String s) {
        s=s.toLowerCase();
        int start=-1;
        int end=-1;
        for (int i=0;i<s.length();i++){
            if (s.charAt(i)!=' '){
                if (start==-1){
                    start=i;
                }
                end=i;
            }
        }
        if (start==-1){
            return false;
        }
        for (int i=start;i<=end;i++){
            if (s.charAt(i)==' '){
                return false;
            }
        }
        s=s.replaceAll(" ","");
        for (int i=0;i<26;i++){
            char low=(char)(i+'a');
            if (i==4){
                if (s.indexOf('e')!=s.lastIndexOf('e')){
                    return false;
                }
            }else if (s.indexOf(low)!=-1){
                return false;
            }
        }
        int t=s.indexOf('e');
        if (t!=-1){
            String big=s.substring(t+1);
            if (big.length()>0 && (big.charAt(0)=='+' || big.charAt(0)=='-')){
                big=big.substring(1);
            }
            if (big.length()==0 || big.indexOf('+')!=-1 || big.indexOf('-')!=-1 || big.indexOf('.')!=-1){
                return false;
            }
        }
        String small=t==-1?s:s.substring(0,t);
        if (small.length()>0 && (small.charAt(0)=='+' || small.charAt(0)=='-')){
            small=small.substring(1);
        }
        if (small.length()==0|| small.indexOf('+')!=-1 || small.indexOf('-')!=-1 || small.indexOf('.')!=small.lastIndexOf('.')){
            return false;
        }
        if (small.length()==1 && small.equals(".")){
            return false;
        }
        return true;
    }

    public static void main(String[] args) {
        System.out.println(new SolutionOffer20().isNumber(". 1"));
    }
}
